
{% extends 'base/base.html' %}

{% block title %}话题列表 - 简易问答平台{% endblock %}

{% block content %}
<div class="page-header">
    <h1>话题列表</h1>
    <a href="{% url 'main:create_topic' %}" class="btn btn-primary">添加话题</a>
</div>

<div class="row">
    {% for topic in topics %}
    <div class="col-md-4">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">{{ topic.name }}</h3>
            </div>
            <div class="panel-body">
                <p>{{ topic.description|truncatechars:100 }}</p>
                <p>
                    问题数量: {{ topic.question_set.count }}
                </p>
                <a href="{% url 'main:topic_detail' topic.pk %}" class="btn btn-sm btn-primary">
                    查看问题
                </a>
            </div>
        </div>
    </div>
    {% empty %}
    <div class="col-md-12">
        <div class="alert alert-info">暂无话题</div>
    </div>
    {% endfor %}
</div>
{% endblock %}
